package com.museum;

import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Vector;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;

import com.museum.data.Mp_Places_Items_Handler;
import com.museum.data.Mp_Places_Museum_Handler;
import com.museum.data.Mp_Places_News_Handler;
import com.museum.data.Mp_User_Bookshelf_Handler;
import com.museum.data.Mp_User_Profile_Handler;
import com.museum.data.Mp_User_Visit_Handler;
import com.museum.data.Mp_User_Watched_Handler;
import com.museum.model.Location;
import com.museum.model.Mp_Places_Items;
import com.museum.model.Mp_Places_Museum;
import com.museum.model.Mp_User_Watched;
import com.museum.model.Open_Date;
import com.museum.model.Open_Date_Item;
import com.museum.model.Place;
import com.museum.model.Visited;
import com.museum.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.support.v4.app.NavUtils;
import android.view.View.OnClickListener;

public class Mp_Places_Museum_Activity extends Activity {
	TextView textviewDetail;
	
	private XMLRPCClient client;
	private URI uri;
	Visited visited;
	Place place;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mp_places_museum);
        
        bindWidget();
        setButtonEventListener();
        
        String place_id = "57";
        String result = "";
        //##############Mp_Places_Museum##################
        Mp_Places_Museum_Handler a = new Mp_Places_Museum_Handler(place_id);
         for(int i = 0;i < a.getMp_Places_Museum().getItemCount(); i++){
         	//Log.d("tag", "##place: " + a.get_Mp_User_Visit().getVisited().getItem(i).getPlaceId());
         	
         	String plc_id = a.getMp_Places_Museum().getItem(i).getPlaceId();
           	String name = a.getMp_Places_Museum().getItem(i).getName();
       	    String description = a.getMp_Places_Museum().getItem(i).getDescription();
       	    String create_timestamp = a.getMp_Places_Museum().getItem(i).getCreate_Timestamp();
       	    String add_timestamp = a.getMp_Places_Museum().getItem(i).getAdded_Timestamp();
       	    String location_description = a.getMp_Places_Museum().getItem(i).getLocation().getDescription();
       	    String location_latitude = a.getMp_Places_Museum().getItem(i).getLocation().getLatitude();
       	    String location_longitude = a.getMp_Places_Museum().getItem(i).getLocation().getLongitude();
       	    String website = a.getMp_Places_Museum().getItem(i).getWebsite();
       	    String email = a.getMp_Places_Museum().getItem(i).getEmail();
       	    result += "\r\nIndex: " + i;
 	      	result += "\r\nplace_id: " + place_id
 	     			 +"\r\n"+ "name: "+ name
 	     			 +"\r\n"+ "description: "+ description
 	     			 +"\r\n"+ "create_timestamp: "+ create_timestamp
 	     			 +"\r\n"+ "add_timestamp: "+ add_timestamp
 	     			 +"\r\n"+ " location_description: "+ location_description
 	     			 +"\r\n"+ " location_latitude: "+ location_latitude
 	     			 +"\r\n"+ " location_longitude: "+ location_longitude
 	     			 +"\r\n"+ "website: "+ website
 	     			 +"\r\n"+ "email: "+ email;
      			 
       	    for(int j=0;j < a.getMp_Places_Museum().getItem(i).getOpen_Date().getItemCount();j++){
       	    	String open_date = a.getMp_Places_Museum().getItem(i).getOpen_Date().getItem(j).getDate();
       	    	String open_time = a.getMp_Places_Museum().getItem(i).getOpen_Date().getItem(j).getOpen_time();
       	    	String close_time = a.getMp_Places_Museum().getItem(i).getOpen_Date().getItem(j).getClose_time();
       	    	
       	    	result += "\r\n"+ " open_date: "+ open_date
 			   			 +"\r\n"+ " open_time: "+ open_time
 			   			 +"\r\n"+ " close_time: "+ close_time;
       	    }
       	    String status = a.getMp_Places_Museum().getItem(i).getStatus();
       	    String exhibition_status = a.getMp_Places_Museum().getItem(i).getExhibition_Status();
       	    
       	  result += "\r\n"+ "status: "+ status
 		   			 +"\r\n"+ "exhibition_status: "+ exhibition_status;
         			    
         }
        textviewDetail.setText(result);
    }
    private void bindWidget(){
    	textviewDetail = (TextView)findViewById(R.id.textviewDetail);
    }
    private void setButtonEventListener(){

    }

}
